# import threading
#
#
# class MyThread(threading.Thread):
#     sum = 0
#
#     def run(self):
#         for i in range(1000000):
#             MyThread.sum += 1
#
#
# thread = MyThread()
# thread2 = MyThread()
# thread3 = MyThread()
# thread.start()
# thread2.start()
# thread3.start()
# thread.join()
# thread2.join()
# thread3.join()
#
# print(MyThread.sum)
#
#


import threading


class MyThread(threading.Thread):
    sum = 0
    lock = threading.Lock()

    def run(self):
        with MyThread.lock:
            for i in range(1000000):
                MyThread.sum += 1


thread = MyThread()
thread2 = MyThread()
thread3 = MyThread()
thread.start()
thread2.start()
thread3.start()
thread.join()
thread2.join()
thread3.join()

print(MyThread.sum)
